package org.yanfengying.mkt.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.yanfengying.dto.ClueActivityDTO;
import org.yanfengying.mkt.domain.ClueActivity;
import org.yanfengying.mkt.mapper.ClueActivityMapper;
import org.yanfengying.mkt.service.IClueActivityService;
import org.yanfengying.utils.service.impl.BastServerImpl;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yanfengying
 * @since 2022-10-24
 */
@Service
public class ClueActivityServiceImpl extends BastServerImpl<ClueActivity> implements IClueActivityService {

    @Autowired
    private ClueActivityMapper activityMapper;
    @Override
    @Transactional
    public void saveActivity(ClueActivityDTO dto) {
        //先删除表里面已有的clue相关活动
        activityMapper.delete(dto.getClueId());
        List<Long> activityIds = dto.getActivityIds();
        activityMapper.saveActivity(dto.getClueId(), activityIds);
        /*for (long activityId: activityIds  ) {
            ClueActivity clueActivity = new ClueActivity();
            clueActivity.setClueId(dto.getClueId());
            clueActivity.setActivityId(activityId);
            activityMapper.insert(clueActivity);
        }*/
    }
}
